(function () {
    const curdFilter = {
        title: "",
        name: "curdFilter_1",
        body: [
            {
                type: "group",
                mode: "horizontal",//水平模式
                body: [
                    {
                        label: "编号",
                        type: "input-text",
                        name: "code",
                        clearable: true
                    },
                ]
            }
        ],
        actions: [
            {
                type: "button",
                label: "新增模板组",
                actionType: "dialog",
                reload: "curdFilter_1.groupCode",
                dialog: {
                    title: "新增模板组",
                    size: "lg",
                    body: {
                        type: "form",
                        api: "post:/api/templateGroup/add",
                        body: [
                            {
                                type: "group",
                                body: [
                                    {
                                        label: "模板组",
                                        type: "input-text",
                                        name: "code",
                                        clearable: true
                                    }
                                ]
                            }
                        ]
                    }
                }
            },
            {
                type: "reset",
                label: "重置"
            },
            {
                type: "submit",
                level: "primary",
                label: "查询"
            }
        ]
    }

    const itemActions = [
        {
            type: "button",
            icon: "fa fa-window-restore",
            tooltip: "复制",
            actionType: "dialog",
            dialog: {
                size: "lg",
                title: "",
                body: [
                    {
                        type: "form",
                        data: {
                            code: "${code}-copy"
                        },
                        api: "/api/templateGroup/copy/${id}",
                        body: [
                            {
                                type: "input-text",
                                name: "code",
                                label: "新编号"
                            }
                        ]
                    }
                ]
            }
        },
        {
            type: "button",
            icon: "fa fa-trash",
            tooltip: "删除",
            actionType: "ajax",
            confirmText: "您确认要删除模板组$id吗?",
            api: "/api/templateGroup/remove/$id"
        }
    ]

    const crud = {
        type: "crud",
        name: "crud_1",
        api: "post:/api/templateGroup/findByCondition",
        orderField: "id",
        affixHeader: true,//开启固定表头功能
        filter: curdFilter,
        mode: "cards",
        card: {
            body: [
                {
                    label: "编号",
                    name: "code"
                }
            ],
            actions: itemActions
        }
    }

    const response = {
        data: {
            type: "page",
            title: "",
            body: [crud]
        },
        status: 0
    }

    window.jsonpCallback && window.jsonpCallback(response);
})();
